from typing import Any

from recruit.adapter.database.models import (
    Resume,
    Base,
)
from tests.adapter.models.utils import check_fields, check_valid_data


def test_resume_model(
        get_resume_models: dict[str, tuple[Base, type[Base]]],
        get_resume: dict[str, Any],
) -> None:
    assert issubclass(Resume, Base)
    resume = Resume(**get_resume)
    check_valid_data(resume, get_resume)
    for key, value in get_resume_models.items():
        # In the case of a list
        if value[1].__name__ in ('ResumeWork', 'ResumeEducation'):
            setattr(resume, key, [value[0]])
            assert len(resume.resume_work) > 0
            assert isinstance(getattr(resume, key)[0], value[1])
        else:
            setattr(resume, key, value[0])
            assert isinstance(getattr(resume, key), value[1])


def test_field() -> None:
    fields = ('id', 'user_id',)
    check_fields(fields, Resume)
